home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / manual / examples / dir.c < prev    next >
C/C++ Source or Header  |  1994-02-16  |  358b  |  26 lines

  1. /*@group*/
  2. #include <stddef.h>
  3. #include <stdio.h>
  4. #include <sys/types.h>
  5. #include <dirent.h>
  6. /*@end group*/
  7.  
  8. int
  9. main (void)
  10. {
  11.   DIR *dp;
  12.   struct dirent *ep;
  13.  
  14.   dp = opendir ("./");
  15.   if (dp != NULL)
  16.     {
  17.       while (ep = readdir (dp))
  18.     puts (ep->d_name);
  19.       (void) closedir (dp);
  20.     }
  21.   else
  22.     puts ("Couldn't open the directory.");
  23.  
  24.   return 0;
  25. }
  26.